<template>
  <view class="container">
    <view v-for="item in list" :key="item.activeId" >
          <uni-card 
          :title="item.activeTitle" 
          :sub-title="item.teamName" 
          :extra="item.address" 
          :thumbnail="item.photo.split(',')[0]"  
          @click="handleOneActive(item.activeId)">
            <text class="uni-body">
              <view class="example-body">
                时间：
                <uni-dateformat class="dateblock" :date="item.startTime" format="MM/dd hh:mm"></uni-dateformat>
                ~
                <uni-dateformat class="dateblock" :date="item.endTime" format="MM/dd hh:mm"></uni-dateformat>
              </view>
            </text>
          </uni-card>
    </view>
    <view class="more" v-if="list.length==0">没有更多消息</view>
  </view>
 
</template>

<script>
  import { getAllMyJoinActive,getActiveByActions  } from '@/api/active/active.js'
   
  export default {
    name:"active-list",
    props:["active","type"],
    data() {
      return {
        status: 'more',
        list: [],
        avatar: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png',
      };
    },
    mounted: function () { //option为object类型，会序列化上个页面传递的参数
          if(this.type=="join"){
              getAllMyJoinActive(this.active).then((Response)=>{
              this.list = Response.rows
              console.log(Response)
              })
            }
          else if(this.type=="nxt"){
              getActiveByActions(this.active).then(Response=>{
                  console.log("=============",Response)
                Response.rows.forEach(item=>{
                  if(item.type!=1){
                    this.list.push(item)
                  }
                })
                console.log(this.list)
                })
          }
          else if(this.type=='fwd'){
            getActiveByActions(this.active).then(Response=>{
                // console.log("=============",Response)
                Response.rows.forEach(item=>{
                    if(item.type!=2){
                        this.list.push(item)
                    }
                })
              })
            }
      },
    
 
    methods: {
        handleOneActive(id){
          console.log("点击了单个活动");
          this.$tab.navigateTo('/pages/work/ActiveDetails/ActiveDetails?id='+id)
        },
      }
  }
</script>

<style lang="scss">
.example-body {
		line-height: 1.5em;
    color: #afab9f;
	}
  .more{
  	width: 90%;
  	height: 50px;
  	line-height: 50px;
  	color: #000000;
  	text-align: center;
  	font-size: 12px;
  }
</style>